package thread;

//创建MyThread类，继续Thread，重写run()方法
//继承 Thread, 重写 run
class MyThread01 extends Thread{
    @Override
    public void run() {
        while(true) {
            System.out.println("hello thread");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }
}

public class Demo01 {
    public static void main(String[] args){
        //创建一个线程对象
        MyThread01 t = new MyThread01();
        //启动线程，执行任务
        t.start();

        //主线执行的任务
        while(true){
            System.out.println("hello main");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }
}
